<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/***************************************************************************
 * 
 * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
 * 
 **************************************************************************/
 
 
 
/**
 * @todo 搜索
 * @package controllers 
 * @file search.php
 * @author lihongliang01@baidu.com
 * @date 2015年1月4日 下午7:41:05
 * 
 *  
 **/
class Search extends MY_APP_Controller {
	
	public function index() {
		$this->loadModel('Post_model', 'article');
		$q = $this->input->get('q', true);
		if (!empty($q)) {
			$map = array(
					'where'=>array('is_show' => 1, 'title like '=>"%{$q}%"),
					'order' => array('sorts'=>'desc','id'=>'desc'),
			);
			$this->assign['result'] = $this->getPager($this->article,$map);
		} else {
			$this->assign['result'] = array('result'=> false);
		}
		//热门文章
		$hotArticles = $this->article->findByField(array('is_hot'=>1), 'sorts desc', 5);
		$this->assign['hot'] = $hotArticles;
		//推荐置顶文章
		$recommends = $this->article->findByField(array('is_top'=>1), 'sorts desc', 5);
		$this->assign['recommends'] = $recommends;
		$this->assign['q'] = $q;
		$this->display();
	}
}
/*End of file search.php*/
/*Location search.php */